/**
 * 
 */
package name.yzhu.httpserver.handle;


import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import name.yzhu.common.ErrorCoder;
import name.yzhu.httpserver.IHttpPermission;

import org.eclipse.jetty.server.handler.AbstractHandler;


/**
 * @author yhzhu
 *
 */
public abstract class AbstractHttpserverHandle extends AbstractHandler{
	protected IHttpPermission rootPermission = null;
	protected ErrorCoder errorCoder = null;
	
	protected boolean processPattern(String target, String pattern,
			List<String> param) {
		Pattern p = Pattern.compile(pattern);
		Matcher m = p.matcher(target);
		if (m.find()){
		  if (m.groupCount() > 0){
			  for (int i=0; i<m.groupCount(); i++)
				  param.add(m.group(i+1));
		  }
		  return true;
		}
		return false;
	}
	
	public void setErrorCoder(final ErrorCoder errcode){
		this.errorCoder = errcode;
	}

	public IHttpPermission getRootPermission() {
		return rootPermission;
	}

	public void setRootPermission(IHttpPermission rootPermission) {
		this.rootPermission = rootPermission;
	}
}
